package com.colde.salary.webservice.controller;

import java.util.Date;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.colde.salary.model.Cat;
import com.colde.salary.service.ICatService;
import com.colde.salary.util.SerialUtil;

@RestController
@RequestMapping("/cat")
public class CatController {

	@Autowired
	private ICatService catService;
	
	@RequestMapping(value = "/add", method = RequestMethod.POST)
	@Transactional
	public Cat addCat(@RequestBody Cat cat) {
		cat.setCarId(SerialUtil.getUid());
		cat.setCreatetime(new Date());
		cat.setUpdatetime(new Date());
		int a = catService.insert(cat);
		
		int c = 1/0;
		cat.setCarId(SerialUtil.getUid());
		cat.setColor("花花绿绿");
		cat.setCreatetime(new Date());
		cat.setUpdatetime(new Date());
		int b = catService.insert(cat);
		
		return cat;
	}
}
